const { Schema, model } = require('mongoose')

const placeSchema = new Schema({
  owner: {
    type: Schema.ObjectId,
    ref: 'User',
    required: true
  },
  createdDate: {
    type: Date,
    required: true,
    index: true,
    default: () => Date.now()
  },
  registration: {
    type: Schema.ObjectId,
    ref: 'Registration'
  },
  area: {
    type: String, // area 表中的code
    required: false
  },
  address: {
    type: String,
    required: true
  },
  deleted: {
    type: Boolean,
    required: true,
    default: () => false
  },
  name: {
    type: String,
    required: true
  },
  status: {
    type: String,
    required: true,
    default: () => 'notFiled'
  },
  note: String
})

const placeModel = model('Place', placeSchema, 'Place')

module.exports = placeModel